using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;

using System.Xml.Serialization;

using AIFSContentManagementSystem;
using AIFSContentManagementSystem.Exceptions;

using AIFSContentManagementSystem.Articles;
using AIFSContentManagementSystem.Articles.Messages;

using AIFSContentManagementSystem.Criteria;
using AIFSContentManagementSystem.Criteria.Messages;
using AIFSCMSFacade;

namespace AIFSCMSService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://www.aifs.org/AIFSCMSService/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class AIFSCMSServiceProvider : System.Web.Services.WebService
    {
        [WebMethod]
        [XmlInclude(typeof(GetFilteredArticleListRequest))]
        [XmlInclude(typeof(ArticleType))]
        [XmlInclude(typeof(Criterion))]
        [XmlInclude(typeof(GetFilteredArticleListResponse))]
        [XmlInclude(typeof(GetFilteredArticleListResponse))]
        public ResponseBase ProcessArticleRequest(ArticleRequest request)
        {
            try
            {
                IFacadeContext facadeContext = new WebserviceFacadeContext();
                AifsCmsFacade facade = new AifsCmsFacade(facadeContext);
                ResponseBase getArticleListRes = facade.ProcessArticleRequestInTransaction(request);
                return getArticleListRes;
            }
            catch (AIFSContentManagementSystemException aex)
            {
                throw aex;
            }
            catch (Exception ex)
            {
                throw new AIFSContentManagementSystemException("Unhandled exception", ex);
            }
        }
    }
}
